//
//  CXVisitorTableViewController.swift
//  Sweibo
//
//  Created by 陈旭 on 16/6/25.
//  Copyright © 2016年 陈旭. All rights reserved.
//

import UIKit

class CXVisitorTableViewController: UITableViewController {

    //标识用户是否登录
    let isLogin:Bool = false
    
    var visitorView:CXVisitorView?
    
    override func loadView() {
        if isLogin{
        
            super.loadView()
        }else{
        
            setupVisitorView()
        }
    }
    
   
    private func setupVisitorView(){
    
        setupNav()
        visitorView =  CXVisitorView()
        visitorView?.closure = {[weak self]in self?.loginClick()}
        view = visitorView
        
    }
    //设置导航栏
    private func setupNav(){
    
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: "loginClick")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "loginClick")
    }

    //mark: - 监听方法
    @objc private func loginClick(){
    
        let authVC = CXOAuthVIewController()
        let navC = UINavigationController(rootViewController: authVC)
        
        presentViewController(navC, animated:true, completion: nil)
        
    }
    override func viewDidLoad() {
        super.viewDidLoad()
        
    }
}
